{extend name="admin/public/base" /}

{block name="content"}
<!-- Content Header (Page header) -->
<section class="content-header">
  <h1>
    幻灯片
    <small></small>
  </h1>
  <ol class="breadcrumb">
    <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
    <li><a href="#">运营</a></li>
    <li class="active">幻灯片</li>
  </ol>
</section>

<!-- Main content -->
<section class="content">

    <div class="box box-solid">
        <div class="box-header with-border">
            <a href="{:Url('admin/slider/create')}" class="btn btn-default btn-flat"><i class="fa fa-plus-square"></i> 创建幻灯片 </a>
            <div class="pull-right">

            </div>
        </div>

        <div class="box-body">
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                        <tr class="unread">
                            <th>#ID</th>
                            <th>标题</th>
                            <th>图片地址</th>
                            <th>描述</th>
                            <th>显示</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                    {volist name="data.list" id="vo"}
                        <tr id = "t_{$vo.id}">
                            <td>{$vo.id}</td>
                            <td><a target="_blank" href="{$vo.url}">{$vo.caption}</a></td>
                            <td><a target="_blank" href="{$vo.url}"><img src="{$vo.image}" height="120"/></a></td>
                            <td>{$vo.content}</td>
                            <td>
                                {eq name="vo.status" value="1"}
                                    <small class="label bg-gray"><i class="fa fa-times"></i></small>
                                {else/}
                                    <small class="label bg-light-blue"><i class="fa fa-check"></i></small>
                                {/eq}
                            </td>
                            
                            <td>
                                <div class="btn-group">
                                    <a href="{:url('admin/slider/edit',['id'=>$vo.id])}" class="btn btn-default btn-xs"><i class="fa fa-edit"></i></a>
                                    <a onClick="deleteOne({$vo.id})" class="btn btn-default btn-xs"><i class="fa fa-trash-o"></i></a>
                                </div>
                            </td>
                        </tr>
                    {/volist}
                    </tbody>
                </table>
            </div>

        </div>
        <div class="box-footer">
            <div class="row">
                <div class="col-sm-6">
                
                </div>

                <div class="col-sm-6">
                    <div class="pull-right">
                        {$data.page}
                    </div>
                </div>
            </div>
        </div>
    </div>

</section>
<!-- /.content -->
{/block}

{block name="js"}
<script>
    function deleteOne(id){
            swal({
                title: "确定删除这条记录吗?",
                text: "",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnConfirm: false,
                closeOnCancel: false },
            function (isConfirm) {
                if (isConfirm) {
                    $.ajax({
                        url:"{:Url('admin/slider/remove')}",
                        data:{'id':id},
                        type:'post',
                        dataType:'json',
                        success: function(xhr){
                            if(xhr.code == 200){
                                swal(xhr.msg, "", "success");
                                $("#t_"+id).remove();
                            }else{
                                swal(xhr.msg, "", "error");
                            }
                        }
                    })
                } else {
                    swal("取消操作", "", "error");
                }
            });
    }
</script>
{/block}
